package com.example.demo555.common;

import com.zaxxer.hikari.HikariDataSource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.boot.jdbc.metadata.HikariDataSourcePoolMetadata;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class ApplicationStartListener implements ApplicationListener<ApplicationReadyEvent> {


    @Override
    public void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent) {
        // 在这里可以答应一些启动时的相关信息
        HikariDataSource dataSource = SpringUtils.getBean(HikariDataSource.class);
        log.info("===============================================");
        log.info("数据库连接地址：{}",dataSource.getJdbcUrl());
        log.info("===============================================");
        log.info("***********************************************");
        log.info("JVM使用内存：{}MB", JvmUtil.totalMemory());
        log.info("***********************************************");

    }

    

}
